package com.ghh.controller;

import com.ghh.domain.Result;
import com.ghh.domain.User;
import com.ghh.service.UserService;
import com.github.pagehelper.PageInfo;
import org.apache.dubbo.config.annotation.Reference;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/user")
public class UserController {

    @Reference
    private UserService userService;

    @RequestMapping("/save")
    public Result save(User user) {
        boolean flag = userService.save(user);
        return new Result(flag);
    }

    @RequestMapping("/pageQuery")
    public Result pageQuery(@RequestParam(required = false, defaultValue = "1") Integer page,
                            @RequestParam(required = false, defaultValue = "5") Integer size) {
        PageInfo pageInfo = userService.pageQuery(page, size);
        return new Result(true, pageInfo);
    }

}
